﻿<html>
<head>
    <meta charset="utf-8">
    <title>layout 管理界面大布局示例 - Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">

    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layui/layui.js"></script>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

</head>
<body>
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo layui-hide-xs layui-bg-black">菜单列</div>
            <div style="float:right;margin-top:10px;margin-right:10px;">
                <span id="username" style="color:white;font-size:18px;"></span>
                <inpu type="button" style="text-align:center;" class="layui-btn layui-btn-normal" onclick="window.location.href='/User/User'">退出登陆
            </div>  
        </div>
     
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <ul class="layui-nav layui-nav-tree" lay-filter="demo-filter-nav">
                    <div id="dynamicMenu"></div>
                </ul>
            </div>
        </div>
        <div class="layui-body" style="padding:10px">
            @RenderBody()
        </div>
    </div>




    <script src="~/js/shared/temp.js"></script>
    <script type="text/javascript">
        $(function () {
            $("dd a").click(function () {
                var ModuleID = $(this).parent().parent().parent().attr("id");
                var PageCode = $(this).parent().attr("id");
                setCookie("ModuleID", ModuleID);
                setCookie("PageCode", PageCode);
            });
            var moduleid = getCookie("ModuleID");
            var pagecode = getCookie("PageCode");
            $("ul li").each(function (index, element) {
                if ($(element).attr("id") != moduleid) {
                    $(this).attr("class", "layui-nav-item");
                }
                else {
                    $(this).attr("class", "layui-nav-item layui-nav-itemed");
                }
            });
            $("dd").each(function (index, element) {
                if ($(element).attr("id") == pagecode) {
                    $(this).attr("class", "layui-this");
                }
            });

            //写cookies
            function setCookie(name, value, key) {
                var Days = 2;
                var exp = new Date();
                exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
                if (key == null || key == "") {
                    document.cookie = name + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() + ";path=/";
                }
                else {
                    var nameValue = getCookie(name);
                    if (nameValue == "") {
                        document.cookie = name + "=" + key + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() + ";path=/";
                    }
                    else {
                        var keyValue = getCookie(name, key);
                        if (keyValue != "") {
                            nameValue = nameValue.replace(key + "=" + keyValue, key + "=" + encodeURI(value));
                            document.cookie = name + "=" + nameValue + ";expires=" + exp.toGMTString() + ";path=/";
                        }
                        else {
                            document.cookie = name + "=" + nameValue + "&" + key + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() + ";path=/";
                        }
                    }
                }
            }

            //读取cookies
            function getCookie(name, key) {
                var nameValue = "";
                var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
                if (arr = document.cookie.match(reg)) {
                    nameValue = decodeURI(arr[2]);
                }
                if (key != null && key != "") {
                    reg = new RegExp("(^| |&)" + key + "=([^(;|&|=)]*)(&|$)");
                    if (arr = nameValue.match(reg)) {
                        alert(decodeURI(arr[2])); return decodeURI(arr[2]);
                    }
                    else return "";
                }
                else {
                    return nameValue;
                }
            }

            //删除cookies
            function delCookie(name) {
                var exp = new Date();
                exp.setTime(exp.getTime() - 1);
                var cval = getCookie(name);
                if (cval != null)
                    document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
            }
        });
    </script>

</body>
</html>